package main

import "fmt"

type Calculator struct {
	method byte
	num1 int
	num2 int
}

func (c Calculator) add() int {
	return c.num1 + c.num2
}

func (c Calculator) reduce() int {
	return c.num1 - c.num2
}

func (c Calculator) by() int {
	return c.num1 * c.num2
}

func (c Calculator) chu() int {
	return c.num1 / c.num2
}

func main() {

	/*
		定义小小计算器结构体(Calculator)，实现加减乘除四个功能。实现形式1：分四个方法完成。实现形式2：用一个方法搞定
	*/

	var c Calculator = Calculator {
		method: '*',
		num1: 1,
		num2: 2,
	}

	if c.method == '*' {
		res := c.by()
		fmt.Println(res)
	}

}